<template>
  <Form :form="form">
    <SchemaField :schema="schema"/>
    <p>
      <Submit @submit="onSubmit">提交</Submit>
    </p>
  </Form>
</template>

<script lang="ts">
import { createForm } from '@formily/core'
import { createSchemaField } from '@formily/vue'
import { Form, FormItem, Checkbox, Submit } from '@formily/vxe-table/src'

const schema = {
  type: 'object',
  properties: {
    section1: {
      type: 'void',
      'x-component': 'p',
      properties: {
        checkbox1: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'medium',
            content: '默认尺寸'
          },
        },
        checkbox2: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'medium',
            content: '中等尺寸'
          },
        },
        checkbox3: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'small',
            content: '小型尺寸'
          },
        },
        checkbox4: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'mini',
            content: '超小尺寸'
          }
        },
        checkbox5: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            indeterminate: true,
            content: '默认尺寸'
          }
        },
        checkbox6: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'medium',
            indeterminate: true,
            content: '中等尺寸'
          }
        },
        checkbox7: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'small',
            indeterminate: true,
            content: '小型尺寸'
          }
        },
        checkbox8: {
          type: 'boolean',
          'x-component': "Checkbox",
          'x-component-props': {
            size: 'mini',
            indeterminate: true,
            content: '超小尺寸'
          }
        },
      }
    },
    section2: {
      type: 'void',
      'x-component': 'p',
      properties: {
        value9: {
          type: 'string',
          'x-component': "Checkbox",
          'x-component-props': {
            content: '复选1'
          }
        },
        value10: {
          type: 'string',
          'x-component': "Checkbox",
          'x-component-props': {
            content: '禁用',
            disabled: true
          }
        },
        value11: {
          type: 'string',
          'x-component': "Checkbox",
          'x-component-props': {
            content: '自定义值',
            checkedValue: "1",
            uncheckedValue: "0"
          }
        }
      }
    },
    value12: {
      type: 'array',
      title: '复选',
      'x-component': 'Checkbox.Group',
      enum: [
        'HTML', 'CSS', 'JavaScript', 'SASS', 'LESS'
      ],
    },
  },
}

const form = createForm()
const {SchemaField} = createSchemaField({
  components: {
    FormItem,
    Checkbox,
  },
})

export default {
  components: {Form, SchemaField, Submit},
  data() {
    return {
      form,
      schema,
    }
  },
  methods: {
    onSubmit(value) {
      console.log(value)
    },
  },
}
</script>
